export default function request (config) {
	// 显示loading动画
	uni.showLoading({
		title: '加载中'
	})
	const { url = '', data = {}, method = 'GET', header = {}} = config
	// Promise<SpecResult<IMyData>> 声明resolve参数的数据类型
	return new Promise((resolve, reject) => {
		uni.request({
			url: 'http://121.89.205.189:3000' + url,
			method,
			data,
			header: {
				'content-type': 'application/json', // 默认值
				token: uni.getStorageSync('token') || ''
			},
			success: (res) => {
				if (res.data.code === '10119') {
					uni.navigateTo({
						url: '/packageUser/pages/login/login'
					})
					// resolve(res)
				} else {
					resolve(res)
				}
			},
			fail: () => {
				reject()
			},
			complete: () => {
				// 取消loading动画
				uni.hideLoading()
			}
		})
	})
}